﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Utilities
{
    public class FileNameUtils
    {
        public static String getValidEmptyFileName(String path, String prex, String postfix)
        {
            String mid = "";
            int i = 1;
            if (postfix.StartsWith(".") == false)
                postfix = "." + postfix;
            if (path.EndsWith("\\") == false)
                path += "\\";

            String fn="";
            while (true)
            {
                fn=String.Format(@"{0}\{1}{2}{3}", path, prex, mid, postfix);
                if (File.Exists(fn) == false)
                    return fn;
                mid = "_["+i.ToString()+"]";
                i++;
            }
         
        }

    }
}
